package com.shop.feignClient;

import com.shop.feignClient.fallbackFactory.DiscountClientFallback;
import com.shop.po.Discount;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "shopping-admin-api",fallbackFactory = DiscountClientFallback.class)
@CrossOrigin
public interface DiscountClient {

    /**
     * 提供Feign调用
     * 通过优惠券ID集合获取到信息
     * @param discountIds
     * @return
     */
    @GetMapping("/getDiscountBatch")
    public List<Discount> getDiscountBatch(@RequestParam("discountIds") List<Long> discountIds);

    //提供Feign接口调用，存在安全问题--->未解决！！！
    //尝试修改优惠券张数
    @PostMapping("/discount/changDiscountCount/{discountId}/{count}")
    public boolean changDiscountCount(@PathVariable("discountId") Long discountId,
                                      @PathVariable("count") Long count);

    @GetMapping("/discount/getDiscountById/{discountId}")
    public Discount getDiscountById(@PathVariable("discountId") Long discountId);
}
